// part1:C10:ex10.12.cpp
// define a compareIsbn() function.
// to compare two isbn() members of Sales_data.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include "Sales_data.h"
using namespace std;

int main(int argc, char *argv[]) {
  ifstream in(argv[1]);
  if (!in) {
    cout << "failed open input file!" << endl;
    exit(1);
  }

  vector<Sales_data> sds;
  Sales_data sd;
  while (read_record(in, sd)) {
    sds.push_back(sd);
  }

  sort(sds.begin(), sds.end(), compareIsbn);
  for (const auto &s: sds) {
    print_record(cout, s);
    cout << endl;
  }

  return 0;
}
